<%-- 
    Document   : sceduledata
    Created on : Jun 6, 2011, 3:09:48 PM
    Author     : javauser
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Schedule Data Page</title>
        <link rel="stylesheet" media="all" type="text/css" href="css/jquery-ui-1.8.6.custom.css" />
        <script type="text/javascript">
           
            function MyMethod()
            {
                var check=true;
                var schedule=document.getElementById("schedule").value;
                if(schedule == 0)
                {
                    document.getElementById("schedulediv").innerHTML="Please,Select Schedule Period";
                    check=false;
                }
                var startdate=document.getElementById("startDate").value;		
                if(startdate.length == 0)
                {		
                    document.getElementById("startDatediv").innerHTML="Please,Enter Starting Date";
                    check=false;
                }		
                var starttime=document.getElementById("startTime").value;
                if(starttime.length==0)
                {
                    document.getElementById("startTimediv").innerHTML="Please,Enter Starting Time";
                    check=false;
                }
                var day=document.getElementById("daydiv").value;
                return check;
            }
            
            function handleselect(){
                var selected=document.getElementById("schedule").value;
                if(selected=="Hourly"){
                    var days=document.getElementById("day");
                    days.style.visibility="hidden";
                    var month=document.getElementById("month");
                    month.style.visibility="hidden";
                }
                if(selected=="Daily"){
                    var days=document.getElementById("day");
                    days.style.visibility="hidden";
                    var month=document.getElementById("month");
                    month.style.visibility="hidden";
                }
                if(selected=="Weekly"){
                    var days=document.getElementById("day");
                    days.style.visibility="visible";  
                    var month=document.getElementById("month");
                    month.style.visibility="hidden";
                    var weekDays=document.getElementById("weekdays");
                    var monthDays=document.getElementById("daysofmonth");
                    weekDays.disabled=true;
                    monthDays.disabled=true;
                }
                if(selected=="Monthly"){
                    var month=document.getElementById("month");
                    var monthDays=document.getElementById("daysofmonth");
                    var months=document.getElementById("monthsdiv");
                    var weekDays=document.getElementById("weekdays");
                    var days=document.getElementById("day");
                    days.style.visibility="hidden";
                    var mod=document.getElementById("modifier").value;
                    if( mod==1 || mod==2 || mod==3 || mod==4 || mod==5 || mod==6 || mod==7 || mod==8 || mod==9 || mod==10 || mod==11 || mod==12){
                        month.style.visibility="visible";
                        monthDays.style.visibility="visible";
                        weekDays.style.visibility="hidden";
                        months.style.visibility="hidden";
                        weekDays.disabled=true;
                        monthDays.disabled=false;
                        days.disabled=false;
                    }
                    if(mod.toLowerCase()=="first" || mod.toLowerCase()=="second" || mod.toLowerCase()=="third" || mod.toLowerCase()=="fourth" || mod.toLowerCase()=="last"){
                        month.style.visibility="visible";
                        weekDays.style.visibility="visible";
                        months.style.visibility="visible";
                        monthDays.style.visibility="hidden";
                        monthDays.disabled=true;
                        weekDays.disabled=false;
                        days.disabled=false;
                    }
                    if(mod.toLowerCase()=="lastday"){
                        month.style.visibility="visible";
                        months.style.visibility="visible";
                        weekDays.style.visibility="hidden";
                        monthDays.style.visibility="hidden";
                        monthDays.disabled=true;
                        weekDays.disabled=true;
                        days.disabled=true;
                    }
                    if(mod==""){
                        month.style.visibility="visible";
                        months.style.visibility="visible";
                        monthDays.style.visibility="visible";
                        weekDays.style.visibility="hidden";
                        weekDays.disabled=true;
                        days.disabled=false;
                        monthDays.disabled=false;
                    }
                }
            }
            
            function display(){
                var days=document.getElementById("day");
                days.style.visibility="hidden";
                var month=document.getElementById("month");
                month.style.visibility="hidden";
            }
        </script>
        <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>

        <style>
            .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
            .ui-timepicker-div dl{ text-align: left; }
            .ui-timepicker-div dl dt{ height: 25px; }
            .ui-timepicker-div dl dd{ margin: -25px 10px 10px 65px; }
            .ui-timepicker-div td { font-size: 90%; }
        </style>
    </head>
    <body onload="display();">
        <script>
            $(function() {
                $( "#startDate" ).datepicker();
            });
            $(function() {
                $('#startTime').timepicker({
                    ampm: false,
                    hourMin: 0,
                    hourMax: 23
                });
            });
        </script>
        <table border="0" style="width:100%;" >
            <html:form action="/AddProviderAction.do" method="post" onsubmit="return MyMethod();">
                <html:hidden property="index" value="scheduledata"/>
                <tr>
                    <td colspan="2" align="center"><h2>Add New provider (Step Four)</h2></td>
                </tr>
                <tr>
                    <td style="width:40%;"><b>Schedule</b>
                    </td>
                    <td  style="width:60%;">
                        <html:select property="schedule" size="1" styleId="schedule" onchange="handleselect();">
                            <html:option value="0">Select Schedule</html:option>
                            <html:option value="Hourly">Hourly</html:option>
                            <html:option value="Daily">Daily</html:option>
                            <html:option value="Weekly">Weekly</html:option>
                            <html:option value="Monthly">Monthly</html:option>
                        </html:select><div id="schedulediv"><html:errors property="EmptySchedule"/></div>
                    </td>
                </tr>
                <tr>
                    <td style="width:40%;"><b>Frequency</b></td>
                    <td style="width:60%;"><html:text property="modifier" styleId="modifier" onblur="handleselect();"></html:text>
                        <div id="modifierdiv"><html:errors property="EmptyModifier"/></div>
                    </td>
                </tr>
                <tr>
                    <td style="width:40%;"><b>Start Date</b></td>
                    <td style="width:60%;"><html:text styleId="startDate" property="startDate"></html:text>
                        <div id="startDatediv"><html:errors property="EmptyStartDate"/></div>
                    </td>
                </tr>
                <tr>
                    <td style="width:40%;"><b>Start Time</b></td>
                    <td style="width:60%;"><html:text styleId="startTime" property="startTime"></html:text>
                        <div id="startTimediv"><html:errors property="EmptyStartTime"/></div>
                    </td>
                </tr>
                <tr id="day">
                    <td style="width:40%;"><b>Day</b>
                    </td>
                    <td  style="width:60%;">
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="FRI"/>FRI
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="SAT"/>SAT
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="SUN"/>SUN
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="MON"/>MON
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="TUE"/>TUE
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="WED"/>WED
                        <INPUT NAME="day" TYPE="CHECKBOX" VALUE="THU"/>THU
                        <div id="daydiv"><html:errors property="EmptyDay"/></div>    
                    </td>
                </tr>
                <tr id="month">
                    <td style="width:40%;"><b>Month</b>
                    </td>
                    <td  style="width:60%;">
                        <div id="monthsdiv">
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="JAN"/>Jan
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="FEB"/>Feb
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="MAR"/>Mar
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="APR"/>Apr
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="MAY"/>May
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="JUN"/>Jun<br>
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="JUL"/>Jul
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="AUG"/>Aug
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="SEP"/>Sep
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="OCT"/>Oct
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="NOV"/>Nov
                            <INPUT NAME="month" TYPE="CHECKBOX" VALUE="DEC"/>Dec</div><br>
                            <html:select property="day" size="1" styleId="weekdays">
                                <html:option value="">Select Day</html:option>
                            <html:option value="FRI">FRI</html:option>
                            <html:option value="SAT">SAT</html:option>
                            <html:option value="SUN">SUN</html:option>
                            <html:option value="MON">MON</html:option>
                            <html:option value="TUE">TUE</html:option>
                            <html:option value="WED">WED</html:option>
                            <html:option value="THU">THU</html:option>
                        </html:select><br>
                        <html:select property="day" size="1" styleId="daysofmonth">
                            <html:option value="">Select Day</html:option>
                            <html:option value="1">1</html:option>
                            <html:option value="2">2</html:option>
                            <html:option value="3">3</html:option>
                            <html:option value="4">4</html:option>
                            <html:option value="5">5</html:option>
                            <html:option value="6">6</html:option>
                            <html:option value="7">7</html:option>
                            <html:option value="8">8</html:option>
                            <html:option value="9">9</html:option>
                            <html:option value="10">10</html:option>
                            <html:option value="11">11</html:option>
                            <html:option value="12">12</html:option>
                            <html:option value="13">13</html:option>
                            <html:option value="14">14</html:option>
                            <html:option value="15">15</html:option>
                            <html:option value="16">16</html:option>
                            <html:option value="17">17</html:option>
                            <html:option value="18">18</html:option>
                            <html:option value="19">19</html:option>
                            <html:option value="20">20</html:option>
                            <html:option value="21">21</html:option>
                            <html:option value="22">22</html:option>
                            <html:option value="23">23</html:option>
                            <html:option value="24">24</html:option>
                            <html:option value="25">25</html:option>
                            <html:option value="26">26</html:option>
                            <html:option value="27">27</html:option>
                            <html:option value="28">28</html:option>
                            <html:option value="29">29</html:option>
                            <html:option value="30">30</html:option>
                            <html:option value="31">31</html:option>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <INPUT TYPE="BUTTON" VALUE="Previous" ONCLICK="window.location.href='providerheaders.jsp'"/> 
                        <html:submit value="Finish"></html:submit>
                        <INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="window.location.href='AdminHome.jsp'"/> 
                    </td>  
                </tr>
            </html:form>    
        </table>
    </body>
</html>
